import template from './feliratkozas.pug';
import popupTemplate from './feliratkozas-popup.pug';
import sikeresFeliratkozasPopupTemplate from './sikeres-feliratkozas-popup.pug';
import sikeresLeiratkozasPopupTemplate from './sikeres-leiratkozas-popup.pug';
import sikertelenPopupTemplate from './sikertelen-popup.pug';
import hirlevelService from './hirlevel-service';
const MODULE_NAME = 'hirlevel';
class HirlevelController {
constructor(hirlevelService, $scope, $uibModal, $location) {
'ngInject';
this._hirlevelService = hirlevelService;
this._$scope = $scope;
this._$uibModal = $uibModal;
this._$location = $location;
}
_showPopup() {
this._$uibModal.open({
animation: true,
template: popupTemplate()
});
}
_showSikeresFeliratkozasPopup() {
this._$uibModal.open({
animation: true,
template: sikeresFeliratkozasPopupTemplate()
});
}
_showSikeresLeiratkozasPopup() {
this._$uibModal.open({
animation: true,
template: sikeresLeiratkozasPopupTemplate()
});
}
_showSikertelenPopup() {
this._$uibModal.open({
animation: true,
template: sikertelenPopupTemplate()
});
}
$onInit() {
this.model = {};
this.captchaUrl = this._getCaptchaUrl();
if (this._$location.search().megerositesToken) {
this._hirlevelService.megerosites(this._$location.search().megerositesToken).then(() => {
this._showSikeresFeliratkozasPopup();
}, () => {
this._showSikertelenPopup();
});
}
if (this._$location.search().leiratkozasToken) {
this._hirlevelService.leiratkozas(this._$location.search().leiratkozasToken).then(() => {
this._showSikeresLeiratkozasPopup();
}, () => {
this._showSikertelenPopup();
});
}
}
_captchaFrissites() {
this.captchaUrl = this._getCaptchaUrl();
}
_getCaptchaUrl() {
return this._hirlevelService.getCaptchaUrl();
}
kuldes(e) {
e.preventDefault();
this._hirlevelService.kuldes(this.model, this.captcha).then(() => {
this._captchaFrissites();
this.model = {};
this.captcha = '';
this._showPopup();
this.errors = null;
}, (err) => {
if (err.status && err.status == 400 && err.data && err.data.errors) {
this.errors = err.data.errors;
} else {
this.technikaiHiba = true;
}
this._captchaFrissites();
this.captcha = '';
});
}
}
angular.module(MODULE_NAME, [hirlevelService])
.component('hirlevel', {
controller: HirlevelController,
template: template(),
bindings: {
wide: '<'
}
});
export default MODULE_NAME;
|